<template>
  <el-dialog title="初验" :visible.sync="visible" fullscreen center append-to-body>
    <el-button class="miui-dialog-close-btn" @click="closeHandle">关闭页面</el-button>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="戴镜史" name="first">
        <div v-if="activeName == 'first'">
          <history-glasses ref="firstDialog"></history-glasses>
        </div>
      </el-tab-pane>
      <el-tab-pane label="屈光检查" name="second">
        <div v-if="activeName == 'second'">
          <check-refractive ref="secondDialog" @addBasic="addBasic"></check-refractive>
        </div>
      </el-tab-pane>
      <el-tab-pane label="双眼视功能检查" name="third">
        <div v-if="activeName == 'third'">
          <check-binoculus ref="thirdDialog" @addBasic="addBasic"></check-binoculus>
        </div>
      </el-tab-pane>
      <el-tab-pane label="相关检查" name="fourth">
        <div v-if="activeName == 'fourth'">
          <check-dependency ref="fourthDialog" @addBasic="addBasic"></check-dependency>
        </div>
      </el-tab-pane>
      <el-tab-pane label="接触镜评估" name="five">
        <div v-if="activeName == 'five'">
          <contact-evaluation ref="fiveDialog" @addBasic="addBasic"></contact-evaluation>
        </div>
      </el-tab-pane>
      <el-tab-pane label="检查结论" name="six">
        <div v-if="activeName == 'six'">
          <check-result ref="sixDialog" @addBasic="addBasic"></check-result>
        </div>
      </el-tab-pane>
      <!-- <el-tab-pane label="角膜接触镜复查" name="seven">
        <div v-if="activeName == 'seven'">
          <check-review ref="sevenDialog"></check-review>
        </div>
      </el-tab-pane> -->
    </el-tabs>
<!--    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="visible = false">确 定</el-button>
    </span> -->
  </el-dialog>

</template>

<script>
  import { mapGetters  } from 'vuex'
  import { filterParams } from '@/util/tools'

  import HistoryGlasses from './item/HistoryGlasses'
  import CheckRefractive from './item/CheckRefractive'
  import CheckBinoculus from './item/CheckDoubleEye'
  import CheckDependency from './item/CheckDependency'
  import ContactEvaluation from './item/ContactEvaluation'
  import CheckResult from './item/CheckResult'
  import CheckReview from './item/CheckReview'


  export default {
    data() {
      return {
        visible: false,
        activeName: 'second',
        customerData: {},
        dataForm: {},
        checkData: {
          checkNumber: '',
          checker: '',
          checkDate: ''
        },
        checkList: [],
        optType: '',
        optOptions: [
          { value: '1', label: '远用' },
          { value: '2', label: '近用' },
          { value: '3', label: '渐进/双光' },
          { value: '4', label: '隐形' },
          { value: '5', label: '中用' },
          { value: '6', label: '角膜塑形' },
          { value: '7', label: '视觉训练' },
        ],
        searchCustomerVisible: false,
        detailCustomerVisible: false,
      }
    },
    components: {
      HistoryGlasses,
      CheckRefractive,
      CheckBinoculus,
      CheckDependency,
      ContactEvaluation,
      CheckResult,
      CheckReview
    },
    computed: {
      ...mapGetters(['permissions', 'bizData', 'userInfo', 'isCollapse'])
    },
    methods: {
      init(data) {
        this.activeName = 'second'
        this.checkData = data.checkData
        this.customerData = data.customer
        this.dataForm.billId = data.billId || 0
        this.visible = true
        this.triggerEvent('second')
      },
      handleClick(tab,event) {
        this.triggerEvent(tab.name)
      },
      triggerEvent(name,id) {
        let data = {
          billId: this.dataForm.billId,
          checkData: this.checkData,
          customer: this.customerData
        }
        this.$nextTick(() => {
          this.$refs[name + 'Dialog'].init(data)
        })
      },
      //  关闭初验
      closeHandle() {
        this.visible = false
        this.$emit('colse')
      },
			//	保存主表
			addBasic(data){
				this.$nextTick(() => {
				  this.$refs[this.activeName + 'Dialog'].saveRefractive(data)
				})
			}
    }
  }
</script>

<style lang="scss" scoped>
  .row-bg {
    background-color: #cadee8;
    padding-left: 15px;
    padding-top: 5px;
  }
  .width-125 {
    width: 125px;
  }
  .miui-table {
    width: 100%;
    margin: 10px 0;
    background-color: #b1e2ec3b;
    tr th {
      background-color: #f4f5f7;
    }

    tr th, tr td {
      padding: 10px 8px;
      border: solid 1px #e7e7e7;
      text-align: center;
    }
    .miui-table-header td{
      background-color: #7898a8;
      color: #fff;
    }
    .miui-table-tbody{
      background-color: #cadee8;
    }
  }
</style>
